<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:s="http://jboss.com/products/seam/taglib"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:a4j="http://richfaces.org/a4j"
	template="businessTypeLayout.xhtml">

	<ui:define name="tlbMainControls">
		<rich:toolBar height="25" itemSeparator="line">
			<rich:toolBarGroup>
				<h:form>
					<h:outputText value="#{messages['txt.quick_search']}   " style="font-weight:bold;" />
					<h:selectOneMenu value="#{businessTypeHelper.searchSelector}">
						<f:selectItem itemValue="#{businessTypeHelper.BY_NAME}" itemLabel="Nombre"/>
					</h:selectOneMenu>
					<h:outputText value="  " />
					<h:inputText value="#{businessTypeHelper.searchText}" />
					<h:outputText value="  " />
					<a4j:commandButton
						value="#{messages['txt.search']}"
						action="#{businessTypeHelper.quickSearch}"
						reRender="frmGrid">
					</a4j:commandButton>
				</h:form>
			</rich:toolBarGroup>
			<rich:toolBarGroup>
				<h:form>
					<a4j:commandButton
						value="Agregar"
						action="#{businessTypeHelper.addNew}"
						reRender="frmEditEntity"
						oncomplete="#{rich:component('editDlg')}.show();">
					</a4j:commandButton>
				</h:form>
			</rich:toolBarGroup>
		</rich:toolBar>
	</ui:define>
	
	<ui:define name="resultGrid">
		<h:form id="frmGrid" style="">
			<h:panelGroup rendered="#{empty businessTypeHelper.entityList}">
				<h:messages style="color:Red;"/>
				<br />
				Ingrese un criterio de busqueda
				<br />
				<br />
				<br />
			</h:panelGroup>
			
			<rich:dataGrid id="grid" value="#{businessTypeHelper.entityList}"
			rendered="#{not empty businessTypeHelper.entityList}" var="entity"
			elements="#{mantUISettingsHelper.numElements}" columns="2" width="100%">
				<f:facet name="header">
					<rich:datascroller maxPages="15"></rich:datascroller>
				</f:facet>
				<f:facet name="footer">
					<rich:datascroller maxPages="15"></rich:datascroller>
				</f:facet>
				
				<table style="width: 100%">
					<tr valign="top">
						<td width="80%">
							<h:panelGrid columns="2">
								<h:outputText value="Nombre: " />
								<h:outputText value="#{entity.name}" />
								
								<h:outputText value="Descripcion: " />
								<h:outputText value="#{entity.description}" />
							</h:panelGrid>
						</td>
						<td>
							<h:panelGrid columns="1">
								<a4j:commandLink
									value="Seleccionar"
									rendered="#{businessTypeHelper.selecting}"
									action="#{businessTypeHelper.select(entity)}"
									reRender="#{businessTypeHelper.reRenderComponents}"
									oncomplete="#{rich:component(selectionPanelName)}.hide();">
								</a4j:commandLink>
								<a4j:commandLink
									value="Editar"
									action="#{businessTypeHelper.edit(entity)}"
									reRender="frmEditEntity"
									oncomplete="#{rich:component('editDlg')}.show();">
								</a4j:commandLink>
								<a4j:commandLink
									value="Ver detalles"
									action="#{businessTypeHelper.view(entity)}"
									reRender="frmEditEntity"
									oncomplete="#{rich:component('editDlg')}.show();">
								</a4j:commandLink>
							</h:panelGrid>
						</td>
					</tr>
				</table>
			</rich:dataGrid>
		</h:form>
	</ui:define>
	
	<ui:define name="res">
		<ui:include src="businessTypeDlgs.xhtml">
			<ui:param name="resultList" value="grid" />
		</ui:include>
	</ui:define>

</ui:composition>
